package com.example.essayjoke;

import android.animation.ValueAnimator;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.Button;

import com.example.BaseLibrary.ioc.OnClick;
import com.example.BaseLibrary.ioc.ViewById;
import com.example.FrameLibrary.BaseSkinActivity;
import com.example.essayjoke.widget.QQStepView;

import java.util.Random;

/**
 * <p>Title: TestActivity</p>
 * <p>Description: </p>
 * <p>Copyright: DS Technology Co.Ltd  Copyright (c) 2020</p>
 * <p>Company: www.ds.cn</p>
 *
 * @author wuguangcheng@ds.cn
 * @version 1.0
 * @date 2021/7/26 15:18
 */
public class TestActivity extends BaseSkinActivity {
    @ViewById(R.id.qq_test)
    QQStepView qqStepView;
    @ViewById(R.id.btn)
    Button button;
    @Override
    public void setContentView() {
        setContentView(R.layout.activity_test);
    }

    @Override
    public void initTitle() {

    }

    @Override
    public void initView() {

        // 拿到 0
        Log.d(TAG, "按钮高度initView():" + button.getMeasuredHeight());

        button.post(new Runnable() {
            @Override
            public void run() {
                // 能拿到
                Log.d(TAG, "按钮高度button.post():" + button.getMeasuredHeight());
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        // 拿到 0
        Log.d(TAG, "按钮高度onResume():" + button.getMeasuredHeight());

    }

    @Override
    public void initData() {
        qqStepView.setStepMax(600);
    }

    @OnClick(R.id.btn)
    public void clickView(View view) {
        ValueAnimator animator = ValueAnimator.ofInt(0, 600).setDuration(1500);
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                qqStepView.setCurrentStep((Integer) animation.getAnimatedValue());
            }
        });
        animator.start();
    }
}
